import logging.handlers
import config.path_cnf as path_cnf


def init_logging():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    fh = logging.handlers.TimedRotatingFileHandler(path_cnf.BASE_DIR + '/log/ego_log.log',
                                                   when='midnight',
                                                   interval=1,
                                                   backupCount=2,
                                                   encoding='utf-8')

    fmt = "%(asctime)s %(levelname)s [%(filename)s(%(funcName)s:%(lineno)d)] - %(message)s"

    formatter = logging.Formatter(fmt)
    fh.setFormatter(formatter)
    logger.addHandler(fh)

if __name__ == '__main__':
    print((path_cnf.BASE_DIR + '/log/ego_log.log'))
